<?php
/**
 * 数据示例
 *
 * Author: Zeon
 * Date: 2017/7/21
 * Time: 16:24
 * Created by PhpStorm.
 */

namespace App\Services\Youzan;


class Mock
{

    public function createOrder()
    {
        $data = [
            "is_success" => true,
            "book_key"   => "201807131628075b4862979c41821231",
            "url"        => "cashier.youzan.com/pay/wsctrade_buy?kdt_id=41040980&book_key=201807131628075b4862979c41821231",
        ];

        return $data;
    }

    public function accessToken()
    {
        $success_data = [
            "access_token"  => "01ab888d1a0338d9aab7e391967b170a",
            "expires_in"    => 604800,
            "refresh_token" => "0e38d0ba7c6b3e26b319771f451a4514",
            "scope"         => "multi_store shop item trade logistics coupon_advanced user pay_qrcode trade_virtual reviews item_category storage retail_goods buyer_bill",
            "token_type"    => "Bearer"
        ];

        $fail_data = [
            "error_description" => "授权码非法",
            "error"             => "41000"
        ];
    }

    public function shop()
    {
        $data = [
            "id"    => "41040980",
            "name"  => "魔妆镜黄村航母店",
            "logo"  => "https://img.yzcdn.cn/upload_files/2018/07/13/Fni5T1YH5lKIN9hi6TLn1bRPIBVG.png",
            "intro" => "测试店铺，不发货，不退款",
        ];
    }

    public function basicShop()
    {
        $data = [
            "sid"          => "18898637",
            "name"         => "yz测试zhangtao10",
            "logo"         => "http://img.yzcdn.cn/111",
            "url"          => "https://h5.youzan.com/v2/showcase/homepage?alias=12oxz98n0",
            "physical_url" => "门店地址",
            "cert_type"    => "认证类型（0 未认证 2 企业认证 3/4 个人认证 6/7/8/9 官方认证）"
        ];
    }

    public function generateOrder()
    {
        $success_data = [
            "is_success" => true,
            "book_key"   => "201808301801435b87c087f2c7743965",
            "url"        => "cashier.youzan.com/pay/wsctrade_buy?kdt_id=41040980&book_key=201808301801435b87c087f2c7743965"
        ];

        $fail_data = [
            "code"    => 53001,
            "message" => "order_type cannot be empty"
        ];
    }

    public function transformOrderLists()
    {
        $data = [
            [
                "customer_id"       => 52,
                "device_account_id" => "350",
                "store_id"          => 147,
                "product_id"        => 3446,
                "trad_no"           => "E20180906111443033900007",
                "created_at"        => "2018-09-06 11:14:43",
                "updated_at"        => "2018-09-06 11:14:46",
                "status_str"        => "待发货",
                "pay_time"          => "2018-09-06 11:14:46",
                "total_fee"         => "0.02",
                "buyer"             => "ZeonWang",
                "refund_state"      => 0,
                "num"               => 1,
                "price"             => "0.01",
                "product_json_data" => [
                    "product_thumb_url" => "https://img.yzcdn.cn/upload_files/2018/09/05/FotaeDmspVB7mr8y2QaWJlOVhpFX.jpg",
                    "product_title"     => "LUNASOL/日月晶采马卡龙柔光净化眼影鲜艳软糯上色哑光",
                ],
            ],
            [
                "customer_id"       => 52,
                "device_account_id" => "350",
                "store_id"          => 147,
                "product_id"        => 4733,
                "trad_no"           => "E20180905180043000900009",
                "created_at"        => "2018-09-05 18:00:43",
                "updated_at"        => "2018-09-05 18:03:49",
                "status_str"        => "已完成",
                "pay_time"          => "2018-09-05 18:00:50",
                "total_fee"         => "0.01",
                "buyer"             => "何德颢",
                "refund_state"      => 0,
                "num"               => 1,
                "price"             => "0.01",
                "product_json_data" => [
                    "product_thumb_url" => null,
                    "product_title"     => null,
                ]
            ]
        ];
    }

    /**
     * 有赞查询到订单列表详情示例
     *
     * @link https://open.youzan.com/apilist/detail/group_trade/trade/youzan.trades.sold.outer.get - 订单接口
     */
    public function queryOrders()
    {
        $orders = [
            [
                /**
                 * @link https://open.youzan.com/apilist/structparam/response/StructurizationTradeOrderInfo
                 */
                "full_order_info" => [
                    "address_info" => [
                        "self_fetch_info"      => "",
                        "delivery_address"     => "香串胡同与高营北胡同交叉口北50米 新世界家园(北门)",
                        "delivery_postal_code" => "165412",
                        "receiver_name"        => "庚哥",
                        "delivery_province"    => "北京市",
                        "delivery_city"        => "北京市",
                        "delivery_district"    => "东城区",
                        // 额外地址是  json 字符串
                        "address_extra"        => "{\"areaCode\":\"110101\",\"lon\":116.42349505418,\"lat\":39.901569914669}",
                        "receiver_tel"         => "15622209229",
                    ],
                    "remark_info"  => [
                        "buyer_message" => "这次总该有信息了吧",
                    ],
                    "pay_info"     => [
                        "outer_transactions" => [],
                        "post_fee"           => "0.01",
                        "total_fee"          => "0.01",
                        "payment"            => "0.02",
                        "transaction"        => [],
                    ],
                    "buyer_info"   => [
                        "buyer_phone"   => "15622209229",
                        "fans_type"     => 1,
                        "buyer_id"      => 286827859,
                        "fans_id"       => 5969572230,
                        "fans_nickname" => "ZeonWang",
                    ],
                    "orders"       => [
                        [
                            "outer_sku_id"        => "",
                            "goods_url"           => "https://h5.youzan.com/v2/showcase/goods?alias=2oqf5lio37h6s",
                            "item_id"             => 424868300,
                            "outer_item_id"       => "77772385",
                            "discount_price"      => "0.01",
                            "item_type"           => 0,
                            "num"                 => 1,
                            "sku_id"              => 36223145,
                            "sku_properties_name" => "[]",
                            "pic_path"            => "https://img.yzcdn.cn/upload_files/2018/09/05/FotaeDmspVB7mr8y2QaWJlOVhpFX.jpg",
                            "oid"                 => "1470100722868034395",
                            "title"               => "LUNASOL/日月晶采马卡龙柔光净化眼影鲜艳软糯上色哑光",
                            // buyer_messages 是 json 字符串
                            "buyer_messages"      => "[{\"store_id\":147,\"device_account_id\":\"350\",\"product_id\":3446,\"type\":\"mirror_app_order\",\"customer_id\":52,\"product_thumb_url\":\"https://img.yzcdn.cn/upload_files/2018/09/05/FotaeDmspVB7mr8y2QaWJlOVhpFX.jpg\",\"product_title\":\"LUNASOL/日月晶采马卡龙柔光净化眼影鲜艳软糯上色哑光\"}]",
                            "is_present"          => false,
                            "pre_sale_type"       => "null",
                            "points_price"        => "0",
                            "price"               => "0.01",
                            "total_fee"           => "0.01",
                            "alias"               => "2oqf5lio37h6s",
                            "payment"             => "0.01",
                            "is_pre_sale"         => "null",
                        ],
                    ],
                    "source_info"  => [
                        "is_offline_order" => false,
                        "source"           => [
                            "platform"    => "wx",
                            "wx_entrance" => "direct_buy",
                        ],
                    ],
                    "order_info"   => [
                        "consign_time"    => "",
                        "order_extra"     => [
                            "is_from_cart"    => "false",
                            "buyer_name"      => "ZeonWang",
                            "is_points_order" => "0",
                        ],
                        "created"         => "2018-09-06 11:14:43",
                        "status_str"      => "待发货",
                        "expired_time"    => "2018-09-06 12:14:43",
                        "success_time"    => "",
                        "type"            => 0,
                        "tid"             => "E20180906111443033900007",
                        "confirm_time"    => "",
                        "pay_time"        => "2018-09-06 11:14:46",
                        "update_time"     => "2018-09-06 11:14:46",
                        "pay_type_str"    => "CODPAY",
                        "is_retail_order" => false,
                        "pay_type"        => 9,
                        "team_type"       => 0,
                        "refund_state"    => 0,
                        "close_type"      => 0,
                        "status"          => "WAIT_SELLER_SEND_GOODS",
                        "express_type"    => 0,
                        "order_tags"      => [
                            "is_use_ump"              => true,
                            "is_secured_transactions" => true,
                            "is_message_notify"       => true,
                        ],
                    ],
                ],
            ],
        ];
    }

    /**
     * 订单详情数据，比订单列表多了 delivery_order / refund_order / order_promotion 信息
     *
     * @link https://open.youzan.com/apilist/detail/group_trade/trade/youzan.trade.get - 订单详情接口
     */
    public function queryOrderDetail()
    {
        $order_detail = [
            /**
             * 物流信息
             *
             * @link https://open.youzan.com/apilist/structparam/response/StructurizationTradeDeliveryDetail[]
             */
            "delivery_order"  => [
                [
                    "pk_id"         => 1469964892206795800,
                    "express_state" => 1,
                    "oids"          => [
                        [
                            "oid" => "1469964810602417083",
                        ],
                    ],
                    "express_type"  => 0,
                ],
            ],
            /**
             * 促销信息
             *
             * @link https://open.youzan.com/apilist/structparam/response/StructurizationTradePromotionInfoDetail
             */
            "order_promotion" => [
                "adjust_fee" => "0.00",
            ],
            /**
             * 退款信息
             *
             * @link https://open.youzan.com/apilist/structparam/response/StructurizationTradeRefundInfoDetail[]
             */
            "refund_order"    => [
                [
                    "refund_type"  => 1,
                    "refund_fee"   => "0.02",
                    "refund_id"    => "201809051745520000030009",
                    "refund_state" => 60,
                    "oids"         => [
                        [
                            "oid" => "1469964810602417083",
                        ],
                    ],
                ],
            ],
            /**
             * 订单信息，在 订单列表接口中 只有这个信息是个详情接口一样的
             *
             * @link https://open.youzan.com/apilist/structparam/response/StructurizationTradeOrderInfo
             */
            "full_order_info" => [
                "address_info" => [
                    "self_fetch_info"      => "",
                    "delivery_address"     => "粤安工业园",
                    "delivery_postal_code" => "",
                    "receiver_name"        => "何德颢",
                    "delivery_province"    => "广东省",
                    "delivery_city"        => "广州市",
                    "delivery_district"    => "天河区",
                    "address_extra"        => "{\"areaCode\":\"440106\",\"lon\":113.41566100605,\"lat\":23.131395671504}",
                    "receiver_tel"         => "15521142905",
                ],
                "remark_info"  => [
                    "buyer_message" => "啦啦啦",
                ],
                "pay_info"     => [
                    "outer_transactions" => [
                        "4200000175201809057924387129",
                    ],
                    "post_fee"           => "0.01",
                    "total_fee"          => "0.01",
                    "payment"            => "0.02",
                    "transaction"        => [
                        "180905173955000063",
                    ],
                ],
                "buyer_info"   => [
                    "fans_type"     => 1,
                    "buyer_id"      => 266079241,
                    "fans_id"       => 5969572291,
                    "fans_nickname" => "何德颢",
                ],
                "orders"       => [
                    [
                        "outer_sku_id"        => "",
                        "goods_url"           => "https://h5.youzan.com/v2/showcase/goods?alias=2oqf5lio37h6s",
                        "item_id"             => 424868300,
                        "outer_item_id"       => "77772385",
                        "discount_price"      => "0.01",
                        "item_type"           => 0,
                        "num"                 => 1,
                        "sku_id"              => 0,
                        "sku_properties_name" => "[]",
                        "pic_path"            => "https://img.yzcdn.cn/upload_files/2018/09/05/FotaeDmspVB7mr8y2QaWJlOVhpFX.jpg",
                        "oid"                 => "1469964810602417083",
                        "title"               => "LUNASOL/日月晶采马卡龙柔光净化眼影鲜艳软糯上色哑光",
                        "buyer_messages"      => "[\"{\\\"store_id\\\":147,\\\"device_account_id\\\":\\\"350\\\",\\\"product_id\\\":3446,\\\"type\\\":\\\"mirror_app_order\\\",\\\"customer_id\\\":52}\"]",
                        "is_present"          => false,
                        "pre_sale_type"       => "null",
                        "points_price"        => "0",
                        "price"               => "0.01",
                        "total_fee"           => "0.01",
                        "alias"               => "2oqf5lio37h6s",
                        "payment"             => "0.01",
                        "is_pre_sale"         => "null",
                    ],
                ],
                "source_info"  => [
                    "is_offline_order" => false,
                    "source"           => [
                        "platform"    => "wx",
                        "wx_entrance" => "direct_buy",
                    ],
                ],
                "order_info"   => [
                    "consign_time"    => "2018-09-05 17:40:32",
                    "order_extra"     => [
                        "is_from_cart"    => "false",
                        "is_points_order" => "0",
                        "settle_time"     => "1536140487243",
                    ],
                    "created"         => "2018-09-05 17:39:54",
                    "status_str"      => "已关闭",
                    "expired_time"    => "2018-09-05 18:39:54",
                    "success_time"    => "2018-09-05 17:41:27",
                    "type"            => 0,
                    "tid"             => "E20180905173954000900003",
                    "confirm_time"    => "",
                    "pay_time"        => "2018-09-05 17:40:00",
                    "update_time"     => "2018-09-05 17:58:10",
                    "pay_type_str"    => "WEIXIN_DAIXIAO",
                    "is_retail_order" => false,
                    "pay_type"        => 10,
                    "team_type"       => 0,
                    "refund_state"    => 12,
                    "close_type"      => 2,
                    "status"          => "TRADE_CLOSED",
                    "express_type"    => 0,
                    "order_tags"      => [
                        "is_use_ump"              => true,
                        "is_secured_transactions" => true,
                        "is_message_notify"       => true,
                        "is_feedback"             => true,
                        "is_refund"               => true,
                        "is_payed"                => true,
                    ],
                ],
            ],
        ];
    }

    /**
     * 有赞商品可设置的留言格式
     */
    public function message()
    {
        [
            [
                "datetime" => 0,
                "editable" => true,
                "multiple" => 0,
                "name"     => "留言1",
                "required" => 0,
                "type"     => "text"
            ],
            [
                "datetime" => 0,
                "editable" => true,
                "multiple" => 0,
                "name"     => "留言2",
                "required" => 0,
                "type"     => "tel"
            ],
            [
                "datetime" => 0,
                "editable" => true,
                "multiple" => 0,
                "name"     => "留言3",
                "required" => 0,
                "type"     => "email"
            ],
            [
                "datetime" => 0,
                "editable" => true,
                "multiple" => 0,
                "name"     => "留言4",
                "required" => 0,
                "type"     => "date"
            ],
            [
                "datetime" => 0,
                "editable" => true,
                "multiple" => 0,
                "name"     => "留言5",
                "required" => 0,
                "type"     => "time"
            ],
            [
                "datetime" => 0,
                "editable" => true,
                "multiple" => 0,
                "name"     => "留言6",
                "required" => 0,
                "type"     => "id_no"
            ],
            [
                "datetime" => 0,
                "editable" => true,
                "multiple" => 0,
                "name"     => "留言7",
                "required" => 0,
                "type"     => "image"
            ],
            [
                "datetime" => 0,
                "editable" => true,
                "multiple" => 0,
                "name"     => "留言8",
                "required" => 0,
                "type"     => "mobile"
            ]
        ];
    }

    /**
     * 有赞商品设置了商品规格的数据结构
     */
    public function skus()
    {
        [
            "skus" => [
                [
                    "sku_unique_code"      => "42486535736248159",
                    "with_hold_quantity"   => 0,
                    "quantity"             => 111,
                    "item_id"              => 424865357,
                    "created"              => "2018-10-08 09:44:56",
                    "price"                => 22200,
                    "properties_name_json" => "[{\"vid\":9970,\"v\":\"2M\",\"kid\":2,\"k\":\"尺寸\"}]",
                    "modified"             => "2018-10-08 09:44:56",
                    "sku_id"               => 36248159,
                    "sold_num"             => 0,
                    "cost_price"           => 6000,
                    "item_no"              => "FGHFGHFT"
                ],
                [
                    "sku_unique_code"      => "42486535736248158",
                    "with_hold_quantity"   => 0,
                    "quantity"             => 111,
                    "item_id"              => 424865357,
                    "created"              => "2018-10-08 09:44:56",
                    "price"                => 11100,
                    "properties_name_json" => "[{\"vid\":421009,\"v\":\"1M\",\"kid\":2,\"k\":\"尺寸\"}]",
                    "modified"             => "2018-10-08 09:44:56",
                    "sku_id"               => 36248158,
                    "sold_num"             => 0,
                    "cost_price"           => 5000,
                    "item_no"              => "FGHFGH"
                ]
            ]
        ];
    }

}